<h1>Path statistics for <%= @subdomain %> </h1>
<%=render(:partial=>'menu')%>
<h2>Last paths</h2>
<div id="path_stats">
  Number of hits:&nbsp;
  <a href='?nh=25&ise=<%=@include_search_engines%>'>25</a>&nbsp;
  <a href='?nh=50&ise=<%=@include_search_engines%>'>50</a>&nbsp;
  <a href='?nh=100&ise=<%=@include_search_engines%>'>100</a>&nbsp;
  <a href='?nh=150&ise=<%=@include_search_engines%>'>150</a>&nbsp;
  <a href='?nh=200&ise=<%=@include_search_engines%>'>200</a>&nbsp;
  <a href='?nh=250&ise=<%=@include_search_engines%>'>250</a>&nbsp; 
  <br/>
  Show search engines: &nbsp;
  <a href='?nh=<%=@number_hits%>&ise=1'>On</a>&nbsp;
  <a href='?nh=<%=@number_hits%>&ise=0'>Off</a>&nbsp;  <br/>
  <% if @paths.size > 0 %>
  <table class="list" width='100%'>
    <tr>
      <th>Timestamp</th>
      <th>Path</th>
      <th>Addr.</th>
      <th>Browser</th>
      <th>Platform</th>
    </tr>
    <% for i in 0..@paths.size-1
         row = @paths[i]
         if not(row.marked?)
           row.mark 
           domain, refferer = "-", '' -%>
    <tr class='<%= alternator %>'> 
      <td width='60px'><div class='cutField'><%=get_time(row.created_at)%></div></td>
      <td width='200px'><div class='cutField'>
          <%       last_access_time = row.created_at
                               # work through loop backwards so we get the *first* page time wise
                               (@paths.size-1).downto(i+1) { |j|
                if not(@paths[j].marked?) and row.remote_ip == @paths[j].remote_ip and (last_access_time - 900 <= @paths[j].created_at)
                  domain, refferer = @paths[j].domain, @paths[j].referer if domain == "-" and @paths[j].domain and not(@paths[j].domain == SITE_NAME)%>
                   <%=get_path_image(@paths[j].resource, @ordered_resources)%>
                   <%           @paths[j].mark
                  last_access_time = @paths[j].created_at
                end
              }
                               # add last page %>
                   <%=get_path_image(row.resource, @ordered_resources)%>  
                   <%       domain, refferer = row.domain, row.referer if domain == "-" and row.domain and not(row.domain == SITE_NAME) %>   
                   <% if domain and not(domain.nil?) and not(domain == '-') %>
                   from &nbsp; <a href="<%=refferer%>"><%=domain%></a>
                   <% end %>   
      </div></td>
      <td><div class='cutField'><%=get_domain_name(row.remote_ip)%></div></td>
      <td width='50px'><div class='cutField'><%=row.browser%>
          <%  unless row.version =="unknown" %>
          &nbsp;<%=row.version%>
          <%  end %>
      </div></td>
      <td width='50px'><div class='cutField'><%=row.platform%></div></td>
    </tr>
    <%    end 
          end %>
  </table>
  <% end %>
</div>

<div id="pathslegend">
  <h2>Legend</h2>
  <% if @orarr.size > 0 %>
          <table class="list">
            <tr><th colspan="2">Resource</th><th>Hits statistics</th></tr>
         <% for resource in @orarr -%>
            <tr class="<%= alternator %>">
    <td><%=get_path_image(resource['resource'], @ordered_resources)%></td>
    <td><a href='<%=resource['resource']%>'><%=h resource['resource'] %></a></td>
    <td><%=resource['requests']%></td></tr>
            <%   end %>
          </table>
          <% end %>
        </div>
</div>
</div>
